package Loganseabolt.weapons;

import java.awt.List;
import java.util.ArrayList;

import net.minecraft.client.renderer.texture.IconRegister;
import net.minecraft.entity.EntityLiving;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.EnumToolMaterial;
import net.minecraft.item.ItemStack;
import net.minecraft.item.ItemSword;
import net.minecraft.potion.Potion;
import net.minecraft.potion.PotionEffect;
import net.minecraft.world.World;
public class MEDIC extends ItemSword 
{
	
	
	public void registerIcons(IconRegister iconReg)
	{
		itemIcon = iconReg.registerIcon("LoganSeaboltModBase:Cross");
	}
	
	
	public MEDIC(int par1, EnumToolMaterial par2EnumToolMaterial) {
		super(par1, par2EnumToolMaterial);
		// TODO Auto-generated constructor stub
	}
	
	
	public boolean hitEntity(ItemStack par1ItemStack, EntityLiving par2EntityLiving, EntityLiving par3EntityLiving)
    {
        par1ItemStack.damageItem(1, par3EntityLiving);
        /*
        this.potionID = par1;
        this.duration = par2;
        this.amplifier = par3;
        this.isAmbient = par4;
        */
        //if ((EntitySkeleton)par2EntityLiving  != null)
        //{
        //	par2EntityLiving.addPotionEffect(new PotionEffect(Potion.heal.id, 5000, 1, false));
        //}
        // if ((EntityZombie)par2EntityLiving != null)
        //{
        	//par2EntityLiving.addPotionEffect(new PotionEffect(Potion.heal.id, 5000, 1, false));
        //}
        par2EntityLiving.addPotionEffect(new PotionEffect(Potion.heal.id, 30, 1, false));
        return true;
    }

	public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer)
	{
		if (!par2World.isRemote)
		{
		    ArrayList<EntityLiving> List1= new ArrayList<EntityLiving>(); 
		    if (par2World.loadedEntityList == null)
		    	return par1ItemStack;
		    for(Object _Entity: par2World.loadedEntityList)
		    {
		    	EntityLiving temp;
		    	try
		    	{
		    		temp = (EntityLiving) _Entity;
		    	}
		    	catch(Exception e)
		    	{
		    		continue;
		    	}
		    	if(temp != null)
		    	{
		    		if (temp.getPosition(1).distanceTo(par3EntityPlayer.getPosition(1)) < 10)
		    		{
		    			temp.addPotionEffect(new PotionEffect(Potion.heal.id, 10, 1, false));
		    		}
		    	}
		    }
		}
		return par1ItemStack;
	}
    public boolean hasEffect(ItemStack par1ItemStack)
    {
        return true;
    }
    
    
}
